package ec.edu.uce.tour.web.menu.componente;

import java.util.ArrayList;
import java.util.List;

import javax.el.ValueExpression;
import javax.faces.component.FacesComponent;
import javax.faces.context.FacesContext;

@FacesComponent(value = "menuSlide")
public class MenuSlideDown extends AbstractMenu  {

	public static final String COMPONENT_TYPE = "ec.edu.uce.tour.web.menu.componente.MenuSlideDown";
	public static final String COMPONENT_FAMILY = "ec.edu.uce.tour.web.menu.componente";
	public static final String DEFAULT_RENDERER = "ec.edu.uce.tour.web.menu.componente.MenuRendered";
	private static final String OPTIMIZED_PACKAGE = "ec.edu.uce.tour.web.menu.componente.";
	
	
	protected enum PropertyKeys {

		label
		,icon
		,styleClass
		,valueTitle
		,valueDesc,
		model;

		String toString;

		PropertyKeys(String toString) {
			this.toString = toString;
		}

		PropertyKeys() {}

		public String toString() {
			return ((this.toString != null) ? this.toString : super.toString());
}
	}
	
	public MenuSlideDown() {
		setRendererType(DEFAULT_RENDERER);
	}

	public String getFamily() {
		return COMPONENT_FAMILY;
	}

	public org.primefaces.model.menu.MenuModel  getModel() {
		return (org.primefaces.model.menu.MenuModel) getStateHelper().eval(PropertyKeys.model, null);
	}
	public void setModel(org.primefaces.model.menu.MenuModel _model) {
		getStateHelper().put(PropertyKeys.model, _model);
		handleAttribute("model", _model);
	}
	
	
	
	public void setValueTitle(java.lang.String _style) {
		getStateHelper().put(PropertyKeys.valueTitle, _style);
		handleAttribute("valueTitle", _style);
	}
	
	public java.lang.String getValueTitle() {
		return (java.lang.String) getStateHelper().eval(PropertyKeys.valueTitle, null);
	}
	
	public void setValueDesc(java.lang.String _style) {
		getStateHelper().put(PropertyKeys.valueDesc, _style);
		handleAttribute("valueDesc", _style);
	}
	
	public java.lang.String getValueDesc() {
		return (java.lang.String) getStateHelper().eval(PropertyKeys.valueDesc, null);
	}
	

	
	public java.lang.String getLabel() {
		return (java.lang.String) getStateHelper().eval(PropertyKeys.label, null);
	}
	public void setLabel(java.lang.String _label) {
		getStateHelper().put(PropertyKeys.label, _label);
		handleAttribute("label", _label);
	}

	public java.lang.String getIcon() {
		return (java.lang.String) getStateHelper().eval(PropertyKeys.icon, null);
	}
	public void setIcon(java.lang.String _icon) {
		getStateHelper().put(PropertyKeys.icon, _icon);
		handleAttribute("icon", _icon);
	}


	public java.lang.String getStyleClass() {
		return (java.lang.String) getStateHelper().eval(PropertyKeys.styleClass, null);
	}
	public void setStyleClass(java.lang.String _styleClass) {
		getStateHelper().put(PropertyKeys.styleClass, _styleClass);
		handleAttribute("styleClass", _styleClass);
	}

   	protected FacesContext getFacesContext() {
		return FacesContext.getCurrentInstance();
	}

	public void handleAttribute(String name, Object value) {
		List<String> setAttributes = (List<String>) this.getAttributes().get("javax.faces.component.UIComponentBase.attributesThatAreSet");
		if(setAttributes == null) {
			String cname = this.getClass().getName();
			if(cname != null && cname.startsWith(OPTIMIZED_PACKAGE)) {
				setAttributes = new ArrayList<String>(6);
				this.getAttributes().put("javax.faces.component.UIComponentBase.attributesThatAreSet", setAttributes);
			}
		}
		if(setAttributes != null) {
			if(value == null) {
				ValueExpression ve = getValueExpression(name);
				if(ve == null) {
					setAttributes.remove(name);
				} else if(!setAttributes.contains(name)) {
					setAttributes.add(name);
				}
			}
		}
	}
	

}
